package applicationmodule;

import applicationmodule.common.AppModule;

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import oracle.adf.model.binding.DCIteratorBinding;

import oracle.jbo.ViewCriteria;
import oracle.jbo.ViewObject;
import oracle.jbo.server.ApplicationModuleImpl;
import oracle.jbo.server.ViewLinkImpl;
import oracle.jbo.server.ViewObjectImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Mon Nov 19 14:46:15 ICT 2012
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class AppModuleImpl extends ApplicationModuleImpl implements AppModule {
    /**
     * This is the default constructor (do not remove).
     */
    public AppModuleImpl() {
    }

    /**
     * Container's getter for DmSanCkView1.
     * @return DmSanCkView1
     */
    public ViewObjectImpl getDmSanCkView1() {
        return (ViewObjectImpl)findViewObject("DmSanCkView1");
    }

    /**
     * Container's getter for VnHastcIndexView1.
     * @return VnHastcIndexView1
     */
    public ViewObjectImpl getVnHastcIndexView1() {
        return (ViewObjectImpl)findViewObject("VnHastcIndexView1");
    }

    /**
     * Container's getter for DmSanCkViewLinks.
     * @return DmSanCkViewLinks
     */
    public ViewObjectImpl getDmSanCkViewLinks() {
        return (ViewObjectImpl)findViewObject("DmSanCkViewLinks");
    }

    /**
     * Container's getter for VnHastcIndexSanViewLink1.
     * @return VnHastcIndexSanViewLink1
     */
    public ViewLinkImpl getVnHastcIndexSanViewLink1() {
        return (ViewLinkImpl)findViewLink("VnHastcIndexSanViewLink1");
    }
    
    public void getBieudotheoSanid(String sanid) {
        ViewObject vo = this.getVnHastcIndexViewBdTheotg1();
        ViewCriteria vc =
            vo.getViewCriteriaManager().getViewCriteria("VnHastcIndexViewBdTheotgCriteria");
        vc.ensureVariableManager().setVariableValue("varsanid", sanid);
        vo.getViewCriteriaManager().removeViewCriteria("VnHastcIndexViewBdTheotgCriteria");
        vo.getViewCriteriaManager().applyViewCriteria(vc);
        vo.executeQuery();
    }
    
    public void getDmsan(String sanid) {
        ViewObject vo = this.getDmSanCkView1();
        ViewCriteria vc =
            vo.getViewCriteriaManager().getViewCriteria("DmSanCkViewCriteria");
        vc.ensureVariableManager().setVariableValue("varsanid", sanid);
        vo.getViewCriteriaManager().removeViewCriteria("DmSanCkViewCriteria");
        vo.getViewCriteriaManager().applyViewCriteria(vc);
        vo.executeQuery();
    }

    public void getBieudotheoTG(String Valuecomb) {
        Date now = new Date();
        Calendar currentDate = Calendar.getInstance();
        
        Timestamp timestamp = new Timestamp(now.getTime());
        oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(timestamp);
        String ngaygiaodich = null;
        if (Valuecomb == "1") {
            SimpleDateFormat sdfDate =
                new SimpleDateFormat("yyyy-MM-dd"); 
            Integer Day =currentDate.get(Calendar.DAY_OF_MONTH);
            Integer Month = currentDate.get(Calendar.MONTH);
            Integer Year = currentDate.get(Calendar.YEAR);
            currentDate.set(Calendar.DAY_OF_MONTH, Day);
            currentDate.set(Calendar.MONTH, Month);
            currentDate.set(Calendar.YEAR, Year);
           
            currentDate.add(Calendar.DAY_OF_MONTH, -6);
            ngaygiaodich = sdfDate.format(currentDate.getTime());
            //System.out.println("ngay giao dich: " + ngaygiaodich);
            
        } else if (Valuecomb == "2") {

        } else if(Valuecomb == "3"){
            
        }
        
        ViewObject vo = this.getVnHastcIndexViewBdTheotg1();
        ViewCriteria vc =
            vo.getViewCriteriaManager().getViewCriteria("VnHastcIndexViewBdTheotgCriteria1");
        vo.ensureVariableManager().setVariableValue("varngaygiaodichht", jboDate.dateValue().toString());
        //System.out.println("ngay giao dich hien tai: " + jboDate.dateValue().toString());
        
        vo.ensureVariableManager().setVariableValue("varngaygiaodich",
                                                    ngaygiaodich);
        vo.getViewCriteriaManager().removeViewCriteria("VnHastcIndexViewBdTheotgCriteria1");
        vo.getViewCriteriaManager().applyViewCriteria(vc);
        vo.executeQuery();
    }
    
    /**
     * Container's getter for VnHastcIndexViewBdTheotg1.
     * @return VnHastcIndexViewBdTheotg1
     */
    public ViewObjectImpl getVnHastcIndexViewBdTheotg1() {
        return (ViewObjectImpl)findViewObject("VnHastcIndexViewBdTheotg1");
    }

    /**
     * Container's getter for DmSanCkViewLinkTg1.
     * @return DmSanCkViewLinkTg1
     */
    public ViewObjectImpl getDmSanCkViewLinkTg1() {
        return (ViewObjectImpl)findViewObject("DmSanCkViewLinkTg1");
    }

    /**
     * Container's getter for VnIndexViewLinkTheoTg1.
     * @return VnIndexViewLinkTheoTg1
     */
    public ViewLinkImpl getVnIndexViewLinkTheoTg1() {
        return (ViewLinkImpl)findViewLink("VnIndexViewLinkTheoTg1");
    }

    /**
     * Container's getter for VnHnxIndexView1.
     * @return VnHnxIndexView1
     */
    public ViewObjectImpl getVnHnxIndexView1() {
        return (ViewObjectImpl)findViewObject("VnHnxIndexView1");
    }

    /**
     * Container's getter for DmSanCkViewLink2.
     * @return DmSanCkViewLink2
     */
    public ViewObjectImpl getDmSanCkViewLink2() {
        return (ViewObjectImpl)findViewObject("DmSanCkViewLink2");
    }

    /**
     * Container's getter for VnHnxIndexViewLinkSanck1.
     * @return VnHnxIndexViewLinkSanck1
     */
    public ViewLinkImpl getVnHnxIndexViewLinkSanck1() {
        return (ViewLinkImpl)findViewLink("VnHnxIndexViewLinkSanck1");
    }
}
